﻿/******************************************************************************************************
Copyright (c) 2014 Steven Giacomelli (stevegiacomelli@gmail.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this 
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify, 
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 
permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies 
or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
******************************************************************************************************/

using System;
using System.Collections.Generic;
using System.Diagnostics;

namespace SharpGeo.IO.WellKnown
{
    /// <summary>
    /// Represents an object representation of a parsed WellKnown (Text or Binary) representation  
    /// </summary>
    [Serializable]
    [DebuggerDisplay("{Keyword}")]
    public class WellKnownGraph
    {
        #region Constructor
        /// <summary>
        /// Constructs an empty WellKnownGraph
        /// </summary>
        public WellKnownGraph() { }
        #endregion

        #region Private Fields
        private WellKnownKeyword _keyword = WellKnownKeyword.Unknown;
        private List<WellKnownGraph> _children = new List<WellKnownGraph>();
        #endregion

        #region Properties
        /// <summary>
        /// Gets and sets the keyword describing this WellKnownGraph
        /// </summary>
        public virtual WellKnownKeyword Keyword
        {
            get { return _keyword; }
            set { _keyword = value; }
        }

        /// <summary>
        /// Gets a child of this WellKnownGraph
        /// </summary>
        /// <param name="index">The index to retrieve the child</param>
        /// <returns>A child of this WellKnownGraph</returns>
        public WellKnownGraph this[int index] { get { return _children[index]; } }
        /// <summary>
        /// Gets the number of children in this WellKnownGraph
        /// </summary>
        public int Count { get { return _children.Count; } }
        #endregion

        #region Methods
        /// <summary>
        /// Adds a child to this WellKnownGraph
        /// </summary>
        /// <param name="child">The child to add to this WellKnownGraph</param>
        public virtual void AddChild(WellKnownGraph child)
        {
            _children.Add(child);
        }

        /// <summary>
        /// Adds a value to this WellKnownGraph
        /// </summary>
        /// <param name="value">The value to add to this WellKnownGraph</param>
        public virtual void AddValue(object value)
        {
            AddChild(new WellKnownData(value));
        }
        #endregion        
    }
}
